﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Churchtoolkit.Utils.Controls
{
    [DefaultProperty("Title")]
    [ToolboxData("<{0}:Window runat=server></{0}:Window>")]
    public class Window : UpdatePanel
    {
        public Window()
        {
            this.ChildrenAsTriggers = true;
            this.UpdateMode = UpdatePanelUpdateMode.Conditional;
        }

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Title
        {
            get
            {
                String s = (String)this.ViewState["title"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["title"] = value;
            }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            if (!Width.IsEmpty)
                writer.AddAttribute(HtmlTextWriterAttribute.Width, Width.ToString());
            if (!Height.IsEmpty)
                writer.AddAttribute(HtmlTextWriterAttribute.Height, Height.ToString());

            writer.AddAttribute("title", Title);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "popup");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            base.Render(writer);
            writer.RenderEndTag();
        }

        private new bool ChildrenAsTriggers
        {
            set
            {
                base.ChildrenAsTriggers = value;
            }
            get
            {
                return base.ChildrenAsTriggers;
            }
        }
        private new UpdatePanelUpdateMode UpdateMode
        {
            set
            {
                base.UpdateMode = value;
            }
            get
            {
                return base.UpdateMode;
            }
        }

        public Unit Width
        {
            get
            {
                var obj = this.ViewState["width"];
                return obj == null ? Unit.Empty : (Unit)obj;
            }
            set
            {
                this.ViewState["width"] = value;
            }
        }

        public Unit Height
        {
            get
            {
                var obj = this.ViewState["height"];
                return obj == null ? Unit.Empty : (Unit)obj;
            }
            set
            {
                this.ViewState["height"] = value;
            }
        }

        public void Show()
        {
 
        }

        public void Hide()
        {
 
        }
    }
}